package link.correction;

import java.io.IOException;

/**
 * This interface defines classes that take a byte stream of
 * input with error correction and then correct error in the stream using
 * the in place error correction and return the byte stream without the error
 * correction, and depending on the quality of the error correction with less
 * to no errors.
 * @author Pim
 *
 */
public interface StreamCorrector {
	
	/**
	 * returns the next available byte if it is available
	 * @return the next available byte
	 * @throws IOException if there is no byte available
	 * @throws NotCorrectableException when the data to be decoded contains errors that can not be corrected
	 * @requires available() > 0
	 */
	 int read() throws IOException, NotCorrectableException;
	 
	 /**
	  * returns the number of available bytes
	  * @return the number of available bytes
	  */
	 int available() throws IOException;
	 
	 /**
	  * indicate that there will be no more bytes after the last byte added
	  * to this StreamCorrector. This is useful for some error correction codes
	  * that might not be perfectly byte aligned
	  */
	 void finish();

}
